<?php
	session_start();
	require("../inc/functions.php");
	if(!isEmployee())
		header("Location: ../index.php");
	require_once("../inc/models/order_details_model.php");
	if(isset($_POST['submit'])){
		$row = $_POST;
		NewOrderDetail($row);
		header("Location: index.php");
	}
	else{
		$customers = GetCustomers();
		$orders = GetOrders();
		$products = GetProducts();
	}
?>

<!DOCTYPE html>
<html lang="en">
	<?php include('../inc/head.php'); ?>
	<body>
	<?php include('../inc/navigation.php'); ?>
			<div class="span9">
				<div class="row-fluid">
					<h2>Create New Company</h2>
					
					<form class="well" method="post" action="#">
						<div class="control-group">
			            	<label class="control-label" for="order_id">Order I.D.:</label>
			             <div class="controls">
			                <select name="order_id" id="order_id">
			                	<?php while($rs = $orders->fetch_assoc()): ?>
			             			<option value="<?=$rs['id'] ?>"><?=$rs['id']?></option>
			             			<?php endwhile; ?>
			                	</select>
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="product_id">Product:</label>
			             <div class="controls">
			                <select name="product_id" id="product_id">
			                	<?php while($rs = $products->fetch_assoc()): ?>
			             			<option value="<?=$rs['id'] ?>"><?=$rs['name']?></option>
			             			<?php endwhile; ?>
			                	</select>
			               </div>
			            </div>
						<div class="control-group">
			            	<label class="control-label" for="name">Order Detail Name:</label>
			             <div class="controls">
			                <input type="text" name="name" id="name"/>
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="price">Price:</label>
			             <div class="controls">
			                <input type="text" name="price" id="price"/>
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="quantity">Quantity:</label>
			             <div class="controls">
			                <input type="text" name="quantity" id="quantity"/>
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="customer_id">Customer:</label>
			             <div class="controls">
			                <select name="customer_id" id="customer_id">
			                	<?php while($rs = $customers->fetch_assoc()): ?>
			             			<option value="<?=$rs['id'] ?>"><?=$rs['first_name']?> <?=$rs['last_name']?></option>
			             			<?php endwhile; ?>
			                	</select>
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="cardtype">Card Type:</label>
			             <div class="controls">
			                <input type="text" name="cardtype" id="cardtype"/>
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="card_number">Card Number:</label>
			             <div class="controls">
			                <input type="text" name="card_number" id="card_number"/>
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="exp_date">Expiration Date:</label>
			             <div class="controls">
			                <input type="text" name="exp_date" id="exp_date"/>
			               </div>
			            </div>
			            <input type="hidden" name="id" id="id" value="<?=$results['id']?>" />
						<input type="submit" name="submit" value="Submit" />
					</form>
				</div>
			</div>
		</div>
	</div>
	
	<!-- All Bootstrap JavaScript Files -->
	<script src="../inc/bootstrap/js/jquery.js"></script>
    <script src="../inc/bootstrap/js/bootstrap.js"></script>
	
	</body>
</html>
